import React, { Component } from 'react';
import { Tabs, WhiteSpace} from 'antd-mobile'


import Header from '@c/navBar/NavHead'
import NoticeLeft from '../ui/NoticeLeft'
import NoticeRight from '../ui/NoticeRight'

import { get } from '@u/http'


class HistoryNotice extends Component {
    state = {
        list:[
            { title: '收到的通知' },
            { title: '发布的通知' }
        ],
        index: 1,
        noticelist:[],
        noticeright: []
    }

    async componentDidMount() {
        let result = await get({
            url: '/api/tongzhi/list?uId=1&send=1'
        })
        let result1 = await get({
            url: '/api/tongzhi/list?uId=1&send=0'
        })

        this.setState({
            noticelist: result.data.list,
            noticeright: result1.data.list,
        })
    }

    
    render() {

        return (
            <div>
                <Header
                title="通知转发"
                {...this.props}
                ></Header>
                <div>
                    <WhiteSpace />
                    <Tabs tabs={this.state.list} initialPage={this.props.location.state === 0 ? 1 : 0} useOnPan={false}>
                        {
                            this.state.noticelist.length > 0 && <NoticeLeft list={this.state.noticelist} ></NoticeLeft>
                        }
                        {
                            this.state.noticelist.length > 0 && <NoticeRight list={this.state.noticeright}></NoticeRight>
                        }
                    </Tabs>
                    <WhiteSpace />
                </div>
            </div>
        );
    }
}

export default HistoryNotice;